"use strict"

/**
 * 江苏政府采购网爬虫
 *  
 */

var Base = require("./base");
var js_spider = new Base();
js_spider.name = "江苏政府采购网";
js_spider.page = 5;

js_spider.getPageUrl = function(pg) {
    var url = "http://www.ccgp-jiangsu.gov.cn/cgxx/cgyg/";
    if (pg != 1) {
        url = "http://www.ccgp-jiangsu.gov.cn/cgxx/cgyg/index_" + pg + ".html";
    }
    return url;
};

js_spider.getItems = function($) {
    var items = [];
    $(".list_list ul li a").each(function(index, ele) {
        var e = $(ele);
        var item = {};
        item.title = e.text();
        e.url = e.attr("href").substring(1);
        item.url = "http://www.ccgp-jiangsu.gov.cn/pub/jszfcg/cgxx/cgyg" + e.url;
        item.source = js_spider.name;
        items.push(item);
    });
    return items;
};

exports = module.exports = js_spider;